<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class ImageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules()
    {
        $user_id = 'required';
        $type = 'required|string|in:avatar,topic';
        $image = '';

        if ($type == 'avatar') {
            $image = 'required|mimes:jgp,png,gif,jpeg|dimensions:min_width=300,min_height=300';
        } else {
            $image = 'required|mimes:jgp,png,gif,jpeg';
        }

        return compact('user_id','type','image');
    }
}
